package com.atguigu.eduservice.controller;

import com.atguigu.commonutils.R;
import com.atguigu.eduservice.entity.User;
import com.atguigu.eduservice.util.SecretUtils;
import com.atguigu.eduservice.util.StrUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName UserController
 * @Description: 脱敏测试类
 * @Author: NeySun
 * @Create: 2022-10-31 14:29
 * @Version 1.0
 **/
@RestController
public class UserController {

    @GetMapping("/users")
    private R getUsers() throws Exception {
        List<User> girls = new ArrayList<>();
        List<User> boys = new ArrayList<>();
        User user = new User();
        user.setName("西施美人");
        user.setAge(18);
        //123456789123456202
        user.setIdCard("12345678912345620X");
        user.getIdCard();
        boolean base64 = StrUtils.isBase64(user.getIdCard());
        System.out.println(base64+"是否是base64");
        //user.setIdCard(SecretUtils.decryptUtil(user.getIdCard()));
        System.out.println(user.getIdCard()+"----------------我的参数");
        user.setMobilePhone("12345678901");
        User user2 = new User();
        user2.setName("杨贵妃");
        user2.setAge(18);
        user2.setIdCard("123456789123456202");
        user2.setMobilePhone("12345678901");
        User user3 = new User();
        user3.setName("古代四大美女之一 * 貂蝉");
        user3.setAge(18);
        user3.setIdCard("123456789123456202");
        user3.setMobilePhone("12345678901");
        User user4 = new User();
        user4.setName("古代四大美女之一 * 王昭君");
        user4.setAge(18);
        user4.setIdCard("123456789123456202");
        user4.setMobilePhone("12345678901");
        User user5 = new User();
        user5.setName(null);
        user5.setAge(18);
        user5.setIdCard(null);
        user5.setMobilePhone(null);
        girls.add(user);
        girls.add(user2);
        girls.add(user3);
        girls.add(user4);
        girls.add(user5);
        for (User girl : girls) {
            User user1 = new User();
            BeanUtils.copyProperties(girl,user1);
            boys.add(user1);
        }
        return R.ok().data("girls",girls);
    }
}
